@(title: String, repository: Option[gitbucket.core.service.RepositoryService.RepositoryInfo] = None)(body: Html)(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.plugin.PluginRegistry
@import gitbucket.core.servlet.AutoUpdate
@import context._
@import gitbucket.core.view.helpers._
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>@title</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <link rel="icon" href="@assets/common/images/gitbucket.png" type="image/vnd.microsoft.icon" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="@assets/vendors/bootstrap-theme-github-3.1.1/css/bootstrap.css" rel="stylesheet">
    @*
    <link href="@assets/vendors/bootstrap-theme-github-3.1.1/css/bootstrap-responsive.css" rel="stylesheet">
    *@
    <link href="@assets/vendors/octicons/octicons.css" rel="stylesheet">
    <link href="@assets/vendors/datepicker/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
    <link href="@assets/vendors/colorpicker/css/bootstrap-colorpicker.css" rel="stylesheet">
    <link href="@assets/vendors/google-code-prettify/prettify.css" type="text/css" rel="stylesheet"/>
    <link href="@assets/vendors/facebox/facebox.css" rel="stylesheet"/>
    <link href="@assets/common/css/gitbucket.css" rel="stylesheet">
    <script src="@assets/vendors/jquery/jquery-1.11.1.js"></script>
    <script src="@assets/vendors/dropzone/dropzone.js"></script>
    <script src="@assets/common/js/validation.js"></script>
    <script src="@assets/common/js/gitbucket.js"></script>
    <script src="@assets/vendors/bootstrap-theme-github-3.1.1/js/bootstrap.js"></script>
    <script src="@assets/vendors/bootstrap3-typeahead/bootstrap3-typeahead.js"></script>
    <script src="@assets/vendors/datepicker/js/moment.js"></script>
    <script src="@assets/vendors/datepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script src="@assets/vendors/colorpicker/js/bootstrap-colorpicker.js"></script>
    <script src="@assets/vendors/google-code-prettify/prettify.js"></script>
    <script src="@assets/vendors/zclip/ZeroClipboard.min.js"></script>
    <script src="@assets/vendors/elastic/jquery.elastic.source.js"></script>
    <script src="@assets/vendors/facebox/facebox.js"></script>
    <script src="@assets/vendors/jquery-hotkeys/jquery.hotkeys.js"></script>
    @repository.map { repository =>
      @if(!repository.repository.isPrivate){
        <meta name="go-import" content="@context.baseUrl.replaceFirst("^https?://", "")/@repository.owner/@repository.name git @repository.httpUrl" />
      }
    }
  </head>
  <body>
    <form id="search" action="@path/search" method="POST" class="form-inline">
      <nav class="navbar navbar-default">
        <div class="container" style="width: 980px;">
          @* TODO: for plugi-ins?
          <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          *@
          <a class="navbar-brand" href="@path/">
            <img src="@assets/common/images/gitbucket.png" style="width: 24px; height: 24px;"/>GitBucket
            @defining(AutoUpdate.getCurrentVersion){ version =>
              <span class="header-version">@version.majorVersion.@version.minorVersion</span>
            }
          </a>
          @if(loginAccount.isDefined){
            @repository.map { repository =>
              <input type="text" name="query" class="form-control" style="width: 200px; margin-bottom: 0px;" placeholder="Search this repository"/>
              <input type="hidden" name="owner" value="@repository.owner"/>
              <input type="hidden" name="repository" value="@repository.name"/>
            }
            <a href="@path/dashboard/pulls" class="global-header-menu">Pull requests</a>
            <a href="@path/dashboard/issues" class="global-header-menu">Issues</a>
          } else {
            @* TODO: merge with below *@
            @repository.map { repository =>
              <input type="text" name="query" class="form-control" style="width: 200px; margin-top: 6px; margin-bottom: 0px;" placeholder="Search this repository"/>
              <input type="hidden" name="owner" value="@repository.owner"/>
              <input type="hidden" name="repository" value="@repository.name"/>
            }
          }
          @if(loginAccount.isDefined){
            <div class="pull-right" style="margin-top: 6px;">
              <div class="btn-group" style="margin-right: 8px;">
                <a class="dropdown-toggle menu" data-toggle="dropdown" href="#">
                  <i class="octicon octicon-plus" style="color: black; font-size: 20px; vertical-align: middle;height:20px !important;"></i><span class="caret" style="color: black; vertical-align: middle;"></span>
                </a>
                <ul class="dropdown-menu pull-right">
                  <li><a href="@path/new">New repository</a></li>
                  <li><a href="@path/groups/new">New group</a></li>
                </ul>
              </div>
              <div class="btn-group">
                <a class="dropdown-toggle menu" data-toggle="dropdown" href="#" data-toggle="tooltip" data-placement="bottom" title="Signed is as @loginAccount.get.userName">
                  @avatar(loginAccount.get.userName, 16)<span class="caret" style="color: black; vertical-align: middle;"></span>
                </a>
                <ul class="dropdown-menu pull-right">
                  <li><a href="@url(loginAccount.get.userName)">Your profile</a></li>
                  <li><a href="@url(loginAccount.get.userName)/_edit">Account settings</a></li>
                  @if(loginAccount.get.isAdmin){
                    <li><a href="@path/admin/users">System administration</a></li>
                  }
                  <li><a href="@path/signout">Sign out</a></li>
                </ul>
              </div>
            </div>
          } else {
            <a href="@path/signin?redirect=@urlEncode(currentPath)" class="btn btn-default pull-right" style="margin-top: 6px;" id="signin">Sign in</a>
          }
        </div>
      </nav>
    </form>
    @body
    <script>
      $(function(){
        $('#search').submit(function(){
          return $.trim($(this).find('input[name=query]').val()) != '';
        });
      });
    </script>
    @PluginRegistry().getJavaScript(request.getRequestURI).map { script =>
      <script>
        @Html(script)
      </script>
    }
  </body>
</html>
